#! /bin/bash
export LANG=zh_CN.UTF-8
PRESTO_HOME=/export/server/presto/bin/presto


${PRESTO_HOME} --catalog hive --server 192.168.88.80:8090 --execute

"insert into hive.edu_rpt.hcx_rpt_day_cnt
select
       time_type,
       create_date_time,
       cus_amt
from hive.edu_dm.hcx_dm_cus_cnt
where  group_type='all' and time_type='day' and create_date_time is not null ;


insert into hive.edu_rpt.hcx_rpt_month_area_cnt
select
       time_type,
       month_time,
       split( cus_area,' ')[2] as shengfeng,
       group_type,
       cus_amt
from hive.edu_dm.hcx_dm_cus_cnt
where group_type='area' and time_type='month' and cus_area like '中国%';

insert into hive.edu_rpt.hcx_rpt_month_chat_area_cnt
select time_type,
       month_time,
       department_name,
       group_type,
       cus_amt
from hive.edu_dm.hcx_dm_cus_cnt
where group_type='chatcenter' and time_type='month' and department_name is not null ;

insert into hive.edu_rpt.kxh_rpt_year_school_cnt_top
select time_type,
       year_time,
       sch_name,
       group_type,
       cus_amt
from hive.edu_dm.hcx_dm_cus_cnt
where group_type='school' and time_type='year' and sch_name is not null ;

insert into hive.edu_rpt.kxh_rpt_year_school_cnt_top
select time_type,
       year_time,
       sch_name,
       group_type,
       cus_amt
from hive.edu_dm.hcx_dm_cus_cnt
where group_type='school' and time_type='year' and sch_name is not null ;



insert into hive.edu_rpt.hcx_rpt_year_sum_clue
with temp1 as
(select
       substring (create_date_time_day,1,4) as year,
       create_date_time_day,
       create_date_time_hour,
       origin_type,
       clue_state,
       cnt_day,
       cnt_hour,
       cnt_hour_good,
       change_rate
from hive.edu_dws.hcx_dws_clu_day_cnt)
select
       year ,
       sum(cnt_day) as year_sum
from temp1
where year is not null
group by year;"
